<%--
  Created by IntelliJ IDEA.
  User: zzz
  Date: 2020/2/5
  Time: 20:20
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="utf-8" />
    <title>所有商品</title>
    <link rel="stylesheet" type="text/css" href="${APP_PATH}/portal/css/public.css"/>
    <link rel="stylesheet" type="text/css" href="${APP_PATH}/portal/css/proList.css"/>
    <link rel="stylesheet" type="text/css" href="${APP_PATH}/css/pagination.css"/>

</head>
<body>
<!------------------------------head------------------------------>
<jsp:include page="/WEB-INF/jsps/Portal/common/top.jsp"/>
<!------------------------------banner------------------------------>
<div class="banner">
    <a href="#"><img src="${APP_PATH}/portal/img/banner1.jpg"/></a>
</div>
<!-----------------address------------------------------->
<div class="address">
    <div class="wrapper clearfix">
        <a href="${APP_PATH}/toPortal">首页</a>
        <span>/</span>
        <a href="javascript:;" class="on">所有商品</a>
    </div>
</div>
<!-------------------current---------------------->
<div class="current">
    <div class="wrapper clearfix">
        <h3 class="fl">所有商品</h3>
        <div class="fr choice">
            <p class="default">排序方式</p>
            <ul id="sort" class="select">
                <li title="5">新品上市</li>
                <li title="1">销量从高到低</li>
                <li title="2">销量从低到高</li>
                <li title="3">价格从高到低</li>
                <li title="4">价格从低到高</li>
            </ul>
        </div>
    </div>
</div>
<!----------------proList------------------------->
<ul id="allGoods" class="proList wrapper clearfix">
</ul>

<div id="paging" class="pagination" style="margin: 0 auto;">
</div>

<!----------------mask------------------->
<div class="mask"></div>
<!-------------------mask内容------------------->
<jsp:include page="/WEB-INF/jsps/Portal/common/skimming.jsp"/>
<!--返回顶部-->
<jsp:include page="/WEB-INF/jsps/Portal/common/gotop.jsp"/>
<div class="msk"></div>
<!--footer-->
<jsp:include page="/WEB-INF/jsps/Portal/common/bottom.jsp"/>
<script src="${APP_PATH}/portal/js/jquery-1.12.4.min.js" type="text/javascript" charset="utf-8"></script>
<script src="${APP_PATH}/portal/js/public.js" type="text/javascript" charset="utf-8"></script>
<script src="${APP_PATH}/portal/js/nav.js" type="text/javascript" charset="utf-8"></script>
<script src="${APP_PATH}/portal/js/pro.js" type="text/javascript" charset="utf-8"></script>
<script src="${APP_PATH}/portal/js/cart.js" type="text/javascript" charset="utf-8"></script>
</body>
</html>

<script>
    var pageNo = 1;
    sort = 0;
    $(function () {
        getAllGoods(pageNo);
        //setInterval("getAllGoods(pageNo,sort)", 5000);
        $("#sort li").click(function () {
            sort = $(this).attr("title");
            getAllGoods(pageNo);
        });
    });

    function getAllGoods(pageNo) {
        $.ajax({
            url : "${APP_PATH}/goods/getAllGoods",
            method : "GET",
            data : {
                pageNo : pageNo,
                sort : sort,
                likeName : '${requestScope.likeName}'
            },
            success : function (result) {
               if(result.success){
                   var furnitureList = result.data.datas;
                   var allGoodsContent = "";
                   pageNo = result.pageNo;
                   for(var i = 0; i < furnitureList.length; i++){
                   allGoodsContent += '<li title="'+furnitureList[i].fid+'">';
                   allGoodsContent += '    <a href="${APP_PATH}/toFurnitureDetail?ktid='+furnitureList[i].kt_ktid+'&fid='+furnitureList[i].fid+'">';
                   allGoodsContent += '        <dl>';
                   allGoodsContent += '        <dt><img src="${APP_PATH}/'+furnitureList[i].fface+'"></dt>';
                   allGoodsContent += '        <dd>'+furnitureList[i].fname+'</dd>';
                   allGoodsContent += '    <dd>￥'+furnitureList[i].fprice.toFixed(2)+'</dd>';
                   allGoodsContent += '    </dl>';
                   allGoodsContent += '    </a>';
                   allGoodsContent += '    </li>';
                   }
                   $("#allGoods").html(allGoodsContent);
                   $("#paging").html(result.data.pageContent);
                   proRender();
               }
            }
        });
    }
</script>